In this script, there is conducted the estimation for the measure_marginal approach for a single given env. The programs is the set of bytecode programs with varying number of opcodes. The measurements are time measurements of program runs or benchmarks. The estimation of each opcode is calculated as the regression against the number of a given opcode in the executed programs.

Parametrization. The evm client name env=revm, the file with programs programs=pg_marginal_full_step5_v2.csv, the file with measurements results=results_marginal_full_revm.csv,
the output csv file with estimated cost output_estimated_cost=reports/estimated_cost_revm_full.csv, should the details be included in the report details=FALSE.

The comparision of result. Before and after removing outlying measurement. Switch removed_outliers to FALSE to see the comparison.

if (removed_outliers) {
  measurements = remove_compare_outliers(measurements, 'measure_total_time_ns', c(env))
}

Now we can investigate the linear regressions.

for (opcode in all_opcodes) {
  estimate = compute_all(opcode=opcode, env=env, use_median=TRUE, plots=ifelse(details,'all','scatter'))
  estimates[nrow(estimates) + 1, ] = c(opcode, estimate, env)
}

The resulting estimates based on the regressions above.

estimates
##                 op estimate_marginal_ns estimate_marginal_ns_stderr  env
## 1              ADD          1.720000000                  0.40471010 revm
## 2              MUL          2.484545455                  0.43131241 revm
## 3              SUB          2.107272727                  0.19940131 revm
## 4              DIV          5.092727273                  0.27413710 revm
## 5             SDIV          8.443636364                  0.14791356 revm
## 6              MOD          5.058181818                  0.27530833 revm
## 7             SMOD          8.670000000                  0.25277723 revm
## 8           ADDMOD         22.820909091                  0.15556733 revm
## 9           MULMOD         12.452727273                  0.09008516 revm
## 10             EXP         23.789090909                  0.24729501 revm
## 11      SIGNEXTEND          8.530000000                  0.24181571 revm
## 12              LT          1.956363636                  0.38278089 revm
## 13              GT          2.295454545                  0.34083231 revm
## 14             SLT          2.684545455                  0.30915493 revm
## 15             SGT          2.817272727                  0.16510536 revm
## 16              EQ          1.681818182                  0.24439727 revm
## 17          ISZERO          1.116363636                  0.37599162 revm
## 18             AND          1.658181818                  0.38368758 revm
## 19              OR          1.489090909                  0.40945169 revm
## 20             XOR          1.268181818                  0.41488102 revm
## 21             NOT          1.200000000                  0.36181615 revm
## 22            BYTE          2.179090909                  0.30304409 revm
## 23             SHL         10.486363636                  0.29244465 revm
## 24             SHR          4.689090909                  0.42984141 revm
## 25             SAR          9.261818182                  0.20122125 revm
## 26       KECCAK256        248.109090909                  0.14067919 revm
## 27         ADDRESS          1.986363636                  0.14178289 revm
## 28          ORIGIN          2.154545455                  0.08865902 revm
## 29          CALLER          1.994545455                  0.09048588 revm
## 30       CALLVALUE          1.750909091                  0.15449910 revm
## 31    CALLDATALOAD          2.284545455                  0.51368696 revm
## 32    CALLDATASIZE          3.355454545                  0.99302522 revm
## 33    CALLDATACOPY          4.529090909                  0.43291737 revm
## 34        CODESIZE          3.729090909                  0.98526965 revm
## 35        CODECOPY          5.052727273                  0.21584523 revm
## 36        GASPRICE          1.874545455                  0.19875554 revm
## 37     EXTCODESIZE          0.122727273                  0.06055680 revm
## 38     EXTCODECOPY         -0.064545455                  0.05657747 revm
## 39  RETURNDATASIZE          3.645454545                  0.99609061 revm
## 40  RETURNDATACOPY          0.099090909                  0.07710261 revm
## 41     EXTCODEHASH          0.131818182                  0.07794126 revm
## 42        COINBASE          2.039090909                  0.08526467 revm
## 43       TIMESTAMP          1.732727273                  0.15547079 revm
## 44          NUMBER          1.996363636                  0.07663971 revm
## 45      DIFFICULTY          2.041818182                  0.08942424 revm
## 46        GASLIMIT          1.838181818                  0.11724414 revm
## 47         CHAINID          3.599090909                  0.99382293 revm
## 48     SELFBALANCE          1.862727273                  0.12467736 revm
## 49             POP          2.146363636                  0.37815693 revm
## 50           MLOAD          2.286363636                  0.47644180 revm
## 51         MSTORE8          2.659090909                  0.41897323 revm
## 52            JUMP          2.362727273                  0.17710533 revm
## 53           JUMPI          2.156363636                  0.22552378 revm
## 54              PC          3.364545455                  0.85479467 revm
## 55           MSIZE          3.700909091                  0.97794311 revm
## 56             GAS          3.651818182                  1.03196617 revm
## 57        JUMPDEST          0.882727273                  0.04031442 revm
## 58           PUSH0          1.788181818                  0.15784679 revm
## 59            LOG0         31.430909091                  0.60837165 revm
## 60            LOG1         51.721818182                  0.57862952 revm
## 61            LOG2         50.050909091                  0.81964538 revm
## 62            LOG3         49.559090909                  0.64468549 revm
## 63            LOG4         52.374545455                  0.61468380 revm
## 64            CALL          0.022727273                  0.05784229 revm
## 65          RETURN          0.012727273                  0.01522407 revm
## 66    DELEGATECALL          0.027272727                  0.09419321 revm
## 67      STATICCALL          0.033636364                  0.06526839 revm
## 68          REVERT          0.007272727                  0.01056703 revm
## 69           PUSH1          2.339090909                  0.37865828 revm
## 70           PUSH2          2.388181818                  0.13504106 revm
## 71           PUSH3          2.415454545                  0.12265467 revm
## 72           PUSH4          2.313636364                  0.12432185 revm
## 73           PUSH5          2.454545455                  0.15042029 revm
## 74           PUSH6          2.401818182                  0.12643883 revm
## 75           PUSH7          2.558181818                  0.21719981 revm
## 76           PUSH8          2.838181818                  0.19873706 revm
## 77           PUSH9          2.294545455                  0.20744721 revm
## 78          PUSH10          2.650909091                  0.11756014 revm
## 79          PUSH11          2.516363636                  0.19427906 revm
## 80          PUSH12          2.401818182                  0.17479254 revm
## 81          PUSH13          2.630909091                  0.20268718 revm
## 82          PUSH14          2.844545455                  0.17408794 revm
## 83          PUSH15          2.978181818                  0.16448266 revm
## 84          PUSH16          2.470000000                  0.17389583 revm
## 85          PUSH17          2.479090909                  0.12575977 revm
## 86          PUSH18          2.353636364                  0.12512583 revm
## 87          PUSH19          2.776363636                  0.14676305 revm
## 88          PUSH20          2.875454545                  0.19791637 revm
## 89          PUSH21          2.577272727                  0.11249528 revm
## 90          PUSH22          2.429090909                  0.17866868 revm
## 91          PUSH23          2.443636364                  0.18059081 revm
## 92          PUSH24          2.509090909                  0.15241551 revm
## 93          PUSH25          2.520909091                  0.12779510 revm
## 94          PUSH26          2.490909091                  0.19072622 revm
## 95          PUSH27          2.575454545                  0.23032516 revm
## 96          PUSH28          2.713636364                  0.15886853 revm
## 97          PUSH29          2.457272727                  0.18148227 revm
## 98          PUSH30          2.395454545                  0.11479810 revm
## 99          PUSH31          2.399090909                  0.12013881 revm
## 100         PUSH32          2.601818182                  0.09937176 revm
## 101           DUP1          1.315454545                  0.36034508 revm
## 102           DUP2          1.978181818                  0.39167461 revm
## 103           DUP3          1.652727273                  0.20860638 revm
## 104           DUP4          1.354545455                  0.37017356 revm
## 105           DUP5          1.641818182                  0.39069574 revm
## 106           DUP6          1.506363636                  0.32970351 revm
## 107           DUP7          1.541818182                  0.37882715 revm
## 108           DUP8          1.718181818                  0.24983006 revm
## 109           DUP9          1.747272727                  0.38733816 revm
## 110          DUP10          1.676363636                  0.37644658 revm
## 111          DUP11          1.530909091                  0.45777680 revm
## 112          DUP12          1.764545455                  0.41818610 revm
## 113          DUP13          1.522727273                  0.37571786 revm
## 114          DUP14          1.623636364                  0.20182455 revm
## 115          DUP15          1.657272727                  0.28719392 revm
## 116          DUP16          1.639090909                  0.27946081 revm
## 117          SWAP1          2.411818182                  0.43405651 revm
## 118          SWAP2          2.559090909                  0.38559639 revm
## 119          SWAP3          2.352727273                  0.44301496 revm
## 120          SWAP4          2.477272727                  0.38116286 revm
## 121          SWAP5          2.590909091                  0.38529442 revm
## 122          SWAP6          2.313636364                  0.44383079 revm
## 123          SWAP7          2.315454545                  0.48614703 revm
## 124          SWAP8          2.479090909                  0.40972241 revm
## 125          SWAP9          2.459090909                  0.41833276 revm
## 126         SWAP10          2.250909091                  0.38803311 revm
## 127         SWAP11          2.394545455                  0.36276714 revm
## 128         SWAP12          2.289090909                  0.48642886 revm
## 129         SWAP13          2.366363636                  0.48044697 revm
## 130         SWAP14          2.425454545                  0.41242146 revm
## 131         SWAP15          2.318181818                  0.31355071 revm
## 132         SWAP16          2.147272727                  0.33958004 revm

The results are exported to reports/estimated_cost_revm_full.csv.